
#!/usr/bin/env bash
#########################################################################
# File Name   : nova.sh.j2
# Author      : seadog
# mail        : seadog0514@163.com
# Version     : 0.1
# Created Time: Mon 2024-09-30 13:17:38(+0800)
#########################################################################

#
# Usage:

{
  set -euo pipefail
}

systemctl restart openvswitch-switch
if ! ip a | grep -q  'br-int:'; then
  ovs-vsctl add-br br-int
fi

# !!! flat if
ip link set {{ network_flat_ifname }} up
# add bridge (any name you like for [br-eth1])
ovs-vsctl add-br br-{{ network_flat_ifname }}
# add a port to the bridge
# replace [eth1] to your own environment
ovs-vsctl add-port br-{{ network_flat_ifname }} {{ network_flat_ifname }}
# map [physnet1] to the bridge (any name you like for [physnet1])
ovs-vsctl set open . external-ids:ovn-bridge-mappings=physnet1:br-{{ network_flat_ifname }}

systemctl restart openvswitch-switch ovn-controller ovn-host
ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
systemctl restart neutron-ovn-metadata-agent
systemctl restart nova-compute
ovs-vsctl set open . external-ids:ovn-remote=tcp:{{ openstack_neutron_ip }}:6642
ovs-vsctl set open . external-ids:ovn-encap-type=geneve,vxlan
ovs-vsctl set open . external-ids:ovn-encap-ip={{ inventory_hostname }}

# !!! set gateway_chassis
# Set ovn-cms-options with enable-chassis-as-gw in Open_vSwitch table’s external_ids
# column. Then if this chassis has proper bridge mappings, it will be selected for
# scheduling gateway routers.
ovs-vsctl set open . external-ids:ovn-cms-options=enable-chassis-as-gw
